package com.css.fxfzmh.util;

import com.alibaba.fastjson.JSONObject;
import org.springframework.data.domain.Page;

public class PlatformPageUtils<T> {
    public static final String CUR_PAGE = "page" ;
    public static final String PAGE_SIZE = "rows";

    public static final String CUR_PAGE_DEF= "1" ;
    public static final String PAGE_SIZE_DEF= "50";

    private static final String ROWS = "rows";
    private static final String TOTAL = "total";
    public static <T> JSONObject formatPageData(Page<T> page){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(ROWS , page.getContent());
        jsonObject.put(TOTAL ,page.getTotalElements());
        return jsonObject;
    }
}
